package com.tnt.hpit.screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Logger;
import com.tnt.hpit.entitys.Ball;
import com.tnt.hpit.gamelogic.GameControl;
import com.tnt.hpit.helper.BallController;
import com.tnt.hpit.helper.Input;
import com.tnt.hpit.helper.MyConnectHelper;
import com.tnt.hpit.services.AtlasManager;
import com.tnt.hpit.shared.Constants;

public class PlayScreen extends AbstractScreen{

	private TextureRegion bgTexture;
	private Ball ball;
	private BallController ballController;
	public PlayScreen(GameControl gameControl) {
		super(gameControl);
		bgTexture = new TextureRegion(AtlasManager.getAtlas().findRegion("bg1"));
		ball = new Ball(sb);
		ballController = new BallController(camera, controllerIM, ball);
	}
	@Override
	public void show() {
		super.show();
		Constants.printLog(this.toString(), "Play screen show");
		controllerIM.getIM().addProcessor(ballController);
	}
	@Override
	public void render(float arg0) {
		super.render(arg0);
		sb.begin();
		sb.draw(bgTexture, 0, 0);
		sb.end();
		ball.render();
		showFrameNumber();
		xuLyInputAdapter();
	}
	private void xuLyInputAdapter(){
//		if ( Input.pressKey( Keys.NUM_2 ))
//			inputMultiplexer.removeProcessor(ballController);
//		inputMultiplexer.getProcessors().
	}
	
	@Override
	public void dispose() {
		super.dispose();
		Constants.printLog(this.toString(), "Play screen dispose");
		Gdx.app.exit();
	}
}
